﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Collections.Generic;
using ScrumTable.Common;
using ScrumTable.DL.Data.Schema;

#endregion

namespace ScrumTable.DL.Data.Common
{
    /// <summary>
    /// Represents and stores the state of a data object.
    /// </summary>
    public class DataObjectState : IDataObjectState
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the ID of the current data object.
        /// </summary>
        /// <value></value>
        public string Id
        {
            get; private set;
        }

        /// <summary>
        /// Gets the underlying system order index. This property can be used
        /// to output the elements in the order given by the data connector.
        /// </summary>
        /// <value></value>
        public double OrderIndex
        {
            get; private set;
        }

        /// <summary>
        /// Gets or sets the internal data values.
        /// </summary>
        public IDictionary<string, object> State
        {
            get; private set;
        }

        /// <summary>
        /// Gets the schema of the underlying data object fields.
        /// </summary>
        public SchemaBase Schema
        {
            get;
            private set;
        }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates a new DataObjectState instance with the specified data.
        /// </summary>
        /// <param name="data">Contains the internal data storage as dictionary. The instance itself will not be stored in the state object.</param>
        /// <param name="dataSchema">Specifies the schema of the given data elements.</param>
        public DataObjectState(IDataObject data, SchemaBase dataSchema)
        {
            PreCondition.AssertNotNull(data, "data");
            PreCondition.AssertNotNull(dataSchema, "dataSchema");

            Schema = dataSchema;
            Id = data.Id;
            OrderIndex = data.OrderIndex;
            State = new Dictionary<string, object>();
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------
        
        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}